home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-installer.exe
/
bin
/
quodlibet
/
parse
/
_scanner.pyc
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2014-12-31
|
2KB
|
47 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
import sre_parse
import sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, lexicon, flags = 0):
self._Scanner__lexicon = lexicon
p = []
s = sre_parse.Pattern()
s.flags = flags
for phrase, action in lexicon:
p.append(sre_parse.SubPattern(s, [
(SUBPATTERN, (len(p) + 1, sre_parse.parse(phrase, flags)))]))
s.groups = len(p) + 1
p = sre_parse.SubPattern(s, [
(BRANCH, (None, p))])
self._Scanner__scaner = sre_compile.compile(p)
def scan(self, string):
result = []
append = result.append
match = self._Scanner__scaner.scanner(string).match
i = 0
while True:
m = match()
if not m:
break
j = m.end()
if i == j:
break
action = self._Scanner__lexicon[m.lastindex - 1][1]
if callable(action):
self.match = m
action = action(self, m.group())
if action is not None:
append(action)
i = j
return (result, string[i:])